Opening a Simple Device by Using the Device Name

The following example opens a CD audio device by specifying the device name.

UINT wDeviceID;

DWORD dwReturn;

MCI_OPEN_PARMS mciOpenParms;

 

// Opens a CD audio device by specifying the device name.

mciOpenParms.lpstrDeviceType = "cdaudio";

if (dwReturn = mciSendCommand(NULL, MCI_OPEN, MCI_OPEN_TYPE,

    (DWORD)(LPVOID) &mciOpenParms))

   

    // Error, unable to open device.

   

// The device opened successfully; get the device ID.

wDeviceID = mciOpenParms.wDeviceID;